<template>
  <el-dialog
    :title="'录入简历'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    >
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
    <el-form-item label="姓名" prop="resName">
      <el-input v-model="dataForm.resName" placeholder="姓名"></el-input>
    </el-form-item>
    <el-form-item label="年龄" prop="resAge">
      <el-input v-model="dataForm.resAge" placeholder="年龄"></el-input>
    </el-form-item>
   
    <el-form-item label="性别" prop="resGender">
       <template>
  <el-radio v-model="dataForm.resGender" label="男">男</el-radio>
  <el-radio v-model="dataForm.resGender" label="女">女</el-radio>
</template>
      
    </el-form-item>
    <el-form-item label="学历" prop="resEducation">
      <template>
  <el-select v-model="dataForm.resEducation" placeholder="请选择">
    <el-option
      v-for="item in options1"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
</template>
      
    </el-form-item>
    <el-form-item label="毕业院校" prop="resCollege">
      <el-input v-model="dataForm.resCollege" placeholder="毕业院校"></el-input>
    </el-form-item>
    <el-form-item label="专业名称" prop="resMajor">
      <el-input v-model="dataForm.resMajor" placeholder="专业名称"></el-input>
    </el-form-item>
    <el-form-item label="毕业时间" prop="resOutCollege">
      <el-input v-model="dataForm.resOutCollege" placeholder="毕业时间"></el-input>
    </el-form-item>
    <el-form-item label="工作年限" prop="resWorkYear">
      <el-input v-model="dataForm.resWorkYear" placeholder="工作年限"></el-input>
    </el-form-item>
    <el-form-item label="手机号码" prop="resMobile">
      <el-input v-model="dataForm.resMobile" placeholder="手机号码"></el-input>
    </el-form-item>
    <el-form-item label="期望工作地区" prop="resExpectedArea">
      <el-input v-model="dataForm.resExpectedArea" placeholder="期望工作地区"></el-input>
    </el-form-item>
    <el-form-item label="期望岗位" prop="resExpectedOccupation">
      <el-input v-model="dataForm.resExpectedOccupation" placeholder="期望岗位"></el-input>
    </el-form-item>
    <el-form-item label="期望月薪" prop="resExpectedSalary">
      <template>
  <el-select v-model="dataForm.resExpectedSalary" placeholder="请选择">
    <el-option
      v-for="item in options2"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
</template>
      
    </el-form-item>
    <el-form-item label="工作经历" prop="resWorkExperience">
      <el-input type="textarea" v-model="dataForm.resWorkExperience" placeholder="工作经历"></el-input>
    </el-form-item>
   
    <el-form-item label="是否同意分享" prop="resShare">
      <template>
  <el-radio v-model="dataForm.resShare" label="1">同意</el-radio>
  <el-radio v-model="dataForm.resShare" label="0">不同意</el-radio>
</template>
      
    </el-form-item>

    <el-form-item label="预约时间" prop="preTime">
      <template>
   <div class="block">
    <span class="demonstration"></span>
    <el-date-picker
      v-model="dataForm.preTime"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
  </div>
</template>
      
    </el-form-item>
    <!-- <el-form-item label="录入人" prop="resHrid">
      <el-input v-model="dataForm.resHrid" placeholder="录入人"></el-input>
    </el-form-item>
    <el-form-item label="来源" prop="resFrom">
      <el-input v-model="dataForm.resFrom" placeholder="来源"></el-input>
    </el-form-item> -->
   
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        
          shortcuts:{
            onClick(picker) {
               picker.$emit('pick', new Date());
             }
           },
        
      

        visible: false,
        dataForm: {
          preTime:'',
          resName: '',
          resAge: '',
          resGender: '男',
          resEducation: '',
          resCollege: '',
          resMajor: '',
          resOutCollege: '',
          resWorkYear: '',
          resMobile: '',
          resExpectedArea: '',
          resExpectedOccupation: '',
          resExpectedSalary: '',
          resWorkExperience: '',
          // resTime: '',
          resShare: '1',
          // resHrid: '',
          // resFrom: '',
          // preTime:'',
        },
      options1: [{
          value: '中专',
          label: '中专'
        }, {
          value: '大专',
          label: '大专'
        }, {
          value: '本科',
          label: '本科'
        }, {
          value: '硕士',
          label: '硕士'
        }, {
          value: '博士',
          label: '博士'
        }],

         options2: [{
          value: '2-4k',
          label: '2-4k'
        }, {
          value: '4-6k',
          label: '4-6k'
        }, {
          value: '6-9k',
          label: '6-9k'
        }, {
          value: '9-12k',
          label: '9-12k'
        }, {
          value: '12-15k',
          label: '12-15k'
        }, {
          value: '15k以上',
          label: '15k以上'
        }],


        dataRule: {
          resName: [
            { required: true, message: '姓名不能为空', trigger: 'blur' }
          ],
          resAge: [
            { required: true, message: '年龄不能为空', trigger: 'blur' }
          ],
          resGender: [
            { required: true, message: '性别不能为空', trigger: 'blur' }
          ],
          resEducation: [
            { required: true, message: '学历不能为空', trigger: 'blur' }
          ],
          resCollege: [
            { required: true, message: '毕业院校不能为空', trigger: 'blur' }
          ],
          resMajor: [
            { required: true, message: '专业名称不能为空', trigger: 'blur' }
          ],
          resOutCollege: [
            { required: true, message: '毕业时间不能为空', trigger: 'blur' }
          ],
          resWorkYear: [
            { required: true, message: '工作年限不能为空', trigger: 'blur' }
          ],
          resMobile: [
            { required: true, message: '手机号码不能为空', trigger: 'blur' }
          ],
          resExpectedArea: [
            { required: true, message: '期望工作地区不能为空', trigger: 'blur' }
          ],
          resExpectedOccupation: [
            { required: true, message: '期望岗位不能为空', trigger: 'blur' }
          ],
          resExpectedSalary: [
            { required: true, message: '期望月薪不能为空', trigger: 'blur' }
          ],
          resWorkExperience: [
            { required: true, message: '工作经历不能为空', trigger: 'blur' }
          ],
         
          resShare: [
            { required: true, message: '是否同意分享不能为空', trigger: 'blur' }
          ],
          preTime: [
            { required: true, message: '预约时间不能为空', trigger: 'blur' }
          ],
         
          
        
        }
      }
    },
    methods: {
     
      init () {
        this.dataForm.resName=''
        this.dataForm.resAge=''
        this.dataForm.resEducation=''
        this.dataForm.resCollege=''
        this.dataForm.resMajor=''
        this.dataForm.resOutCollege=''
        this.dataForm.resWorkYear=''
        this.dataForm.resMobile=''
        this.dataForm.resExpectedArea=''
        this.dataForm.resExpectedOccupation=''
        this.dataForm.resExpectedSalary=''
        this.dataForm.resWorkExperience=''
        this.dataForm.preTime=''

        this.visible = true
       
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/generator/resume/save`),
              method: 'post',
              data: this.$http.adornData({
                // 'resId': this.dataForm.resId || undefined,
                'resName': this.dataForm.resName,
                'resAge': this.dataForm.resAge,
                'resGender': this.dataForm.resGender,
                'resEducation': this.dataForm.resEducation,
                'resCollege': this.dataForm.resCollege,
                'resMajor': this.dataForm.resMajor,
                'resOutCollege': this.dataForm.resOutCollege,
                'resWorkYear': this.dataForm.resWorkYear,
                'resMobile': this.dataForm.resMobile,
                'resExpectedArea': this.dataForm.resExpectedArea,
                'resExpectedOccupation': this.dataForm.resExpectedOccupation,
                'resExpectedSalary': this.dataForm.resExpectedSalary,
                'resWorkExperience': this.dataForm.resWorkExperience,
                // 'resTime': this.dataForm.resTime,
                'resShare': this.dataForm.resShare,
                // 'resHrid': this.dataForm.resHrid,
                // 'resFrom': this.dataForm.resFrom,
                'preTime':this.dataForm.preTime,
                
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
